package cn.toys.modular.controller;

import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.toys.base.pojo.page.LayuiPageFactory;
import cn.toys.modular.entity.CityArea;
import cn.toys.modular.model.CompanyDto;
import cn.toys.modular.service.ICityAreeaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 区域管理
 *
 * @author guoyu
 * @version 1.0
 * @date 2021/3/15 9:38 下午
 */
@Controller
@RequestMapping("/area")
public class CityAreaController extends BaseController {

    @Autowired
    private ICityAreeaService cityAreeaService;

    @GetMapping(value = "/list")
    @ResponseBody
    public Object list(String areaLevel, Long parentAreaCode) {
        CityArea cityArea = new CityArea();
        cityArea.setAreaLevel(areaLevel);
        cityArea.setParentAreaCode(parentAreaCode);
        List<CityArea>  list = cityAreeaService.list(cityArea);
        Long total =  list != null && list.size()>0?list.size():0L;
        return LayuiPageFactory.createPageInfo(total,list);
    }
}
